package cn.xxstudy.blog.entity;

import org.hibernate.validator.constraints.NotBlank;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * 作者：xinxi on 2020/11/24 22:42
 * 包名：cn.xxstudy.blog.entity
 * TODO：分类表
 */
@Entity
@Table(name = "personal_category")
public class Category {
    @Id
    @GeneratedValue
    private Long id;

    @OneToMany(mappedBy = "category")
    private List<Blog> blogs = new ArrayList<>();

    @NotBlank(message = "分类名称不能为空")
    private String categoryName;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public List<Blog> getBlogs() {
        return blogs;
    }

    public void setBlogs(List<Blog> blogs) {
        this.blogs = blogs;
    }

    public String getCategoryName() {
        return categoryName;
    }

    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }

    @Override
    public String toString() {
        return "Category{" +
                "id=" + id +
                ", categoryName='" + categoryName + '\'' +
                '}';
    }
}
